import axios from 'axios'

const serverApi = process.env.REACT_APP_API

/**
 * 根据获取房间信息
 */
export const getRoomCanJoin = (roomId) => {
  return axios.get(`${ serverApi }/room/canJoin/${ roomId }`).then(res => res.data).catch(err => Promise.reject(err.response))
}
/**
 * 创建房间
 */
export const postRoom = (userId) => {
  return axios.post(`${ serverApi }/room`, { userId }).then(res => res.data).catch(err => Promise.reject(err.response))
}
/**
 * 修改用户基本资料
 */
export const putUserInfo = ({ userId, ...user }) => {
  return axios.put(`${ serverApi }/user/${ userId }`, user).then(res => res.data).catch(err => Promise.reject(err.response))
}
